package com.yzh.design.demo.impl;

import com.yzh.design.demo.ICouponDiscount;

import java.math.BigDecimal;

/**
 * 折扣
 */
public class ZKCouponDiscount implements ICouponDiscount<String> {
    @Override
    public BigDecimal discountAmount(String couponInfo, BigDecimal skuPrice) {
        BigDecimal val = skuPrice.multiply(new BigDecimal(couponInfo).setScale(2, BigDecimal.ROUND_HALF_UP));   //四舍五入
        if (val.compareTo(BigDecimal.ZERO) < 1) return BigDecimal.ZERO;
        return val;
    }
}
